package com.zunke.shopmanager.service.impl;

import com.zunke.shopmanager.mapper.DishesMapper;
import com.zunke.shopmanager.pojo.Dishes;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//@Service
//public class UploadServiceImpl {
//    @Resource
//    private DishesMapper dishesMapper;
//
//    public Map<String, Object> uploadPhoto(MultipartFile file, String id, HttpServletRequest request) throws IOException, FileUploadException, SQLException, ClassNotFoundException {
//        Map<String, Object> map = new HashMap<>();
//        String abPath = "upload/photo";
//        String uploadPath = request.getServletContext().getRealPath("") + File.separator + abPath + File.separator;
//        String fileName = file.getOriginalFilename();
//        File newFile = new File(uploadPath + fileName);
//        FileCopyUtils.copy(file.getBytes(), newFile);
//        String userSQLPath = File.separator + abPath + File.separator + fileName;
//        dishesMapper.updatePhoto(userSQLPath, id);
//        map.put("code", 200);
//        map.put("msg", "上传图片成功");
//        map.put("data", userSQLPath);
//        return map;
//    }
//
//}
